#ifndef STATETAKEOFF_H
#define STATETAKEOFF_H

#include "state.h"
#include "stateid.h"
#include "../manager.h"
#include "../eventmanager.h"
#include "../parammanager.h"
#include "../properties.h"


namespace state {

const uint32_t TAKEOFF_TIME = 500;
	

struct TakeoffRolling : public State {
	TakeoffRolling(int id) : State(id) {}
	
	virtual void onEnter() {
		PropAccessor p;
		p().fcs.roll.set(Roll_Neutral);
		p().fcs.pitch.set(Pitch_Neutral);
		p().fcs.yaw.set(Yaw_Neutral);
		p().fcs.throttle.set(Throttle_Value, 1, 0.3f);
		p().fcs.flaps.set(Flaps_Value, Flaps_Value_Takeoff);
		p().fcs.brakes.set(Brakes_Value, 0);
		p().fcs.state = getId();
		
		p().fcs.parachute_armed = false;		
	}
};


struct TakeoffRotate : public State {
	TakeoffRotate(int id) : State(id) {}
	
	virtual void onEnter() {
		Manager::Instance().getRoute()->flyTo(0);
		Manager::Instance().getEventManager()->setTimer(TAKEOFF_TIME);

		PropAccessor p;
		p().fcs.roll.set(Roll_SetPoint, 0);
		p().fcs.pitch.set(Pitch_Direct, Manager::Instance().getParamManager()->getFloat(ParamManager::ELEVATOR_TAKEOFF));
		p().fcs.yaw.set(Yaw_Neutral);
		p().fcs.throttle.set(Throttle_Value, 1);
		p().fcs.flaps.set(Flaps_Value, Flaps_Value_Takeoff);
		p().fcs.brakes.set(Brakes_Value, 0);
		p().fcs.state = getId();
		
		p().fcs.parachute_armed = false;		
	}
};


}

#endif
